import Vue from 'vue'

import Cookies from 'js-cookie'
import yz from '@/views/wish/yz'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'
import enLang from 'element-ui/lib/locale/lang/en'// 如果使用中文语言包请默认支持，无需额外引入，请删除该依赖

import '@/styles/index.scss' // global css
import axios from "axios";
import App from './App'
import store from './store'
import router from './router'

import QRCode from "qrcode"; //引入生成二维码插件
Vue.prototype.QRCode=QRCode;

import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log



import * as filters from './filters' // global filters
// 请求拦截器
axios.interceptors.request.use(
  config => {
    console.log("阿巴巴巴叭叭叭别",localStorage.getItem("access_token"))
    if (localStorage.getItem("access_token") != null
      && localStorage.getItem("access_token") !== undefined
      && config.url.indexOf('oauth/token') === -1
      // access_toaken如果存在并且不是登录接口，则统一在http请求的prams都加上access_token，这样后台根据access_token判断你的登录情况，
      //在这里插一嘴axios的请求设置头name后台接收时必须也设置接收这个请求头name（一一对应）,否者会报415
    ) {
      console.log("叭叭叭别",localStorage.getItem("access_token"))
      config.params = {
        access_token: localStorage.getItem("access_token"),
        ...config.params
      }
      // config.data.push("access_token",localStorage.getItem("access_token"));
    }
    return config;
  },
  err => Promise.reject(err)
);




/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
 // locale: enLang // 如果使用中文，无需设置，请删除
},axios,yz)

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
